#include "core_pch.h"
#include "core.h"
#include "SString.h"
#include "Res.h"

s32_t __reportStrDataNum();

#define __crc_ploy 0x04c11db7
u32_t __crcTable[256];


//unitity
u32_t _strHash( const as_char_t* str, s32_t mod)
{
	u32_t hshVal=0;
	while( *str )
	{
		hshVal = ((hshVal >> 8) & 0x00FFFFFF) ^ __crcTable[(hshVal ^ (*str++)) & 0x000000FF];
	}
	return hshVal%mod;
}

void InitCoreRTTI();

void CoreInit()
{
	// Init CRC
    for( u32_t i=0; i<256; i++ )
		for( u32_t c=i<<24, j=8; j!=0; j-- )
			__crcTable[i] = c = c & 0x80000000 ? (c << 1) ^ __crc_ploy : (c << 1);

	SString::StaticInit();

	InitCoreRTTI();
}

void CoreShutdown()
{
	_check( 0 == __reportStrDataNum());

	Pack::sPackMap.Clear();
	SString::StaticShutdown();
	ClassDef::Shutdown();
	EventDef::sEventArray.Clear();
}

